//
//  AZSendDataTypeController.m
//  AZBLE
//
//  Created by AZ-Mac on 2017/5/4.
//  Copyright © 2017年 AZ-Mac. All rights reserved.
//

#import "AZSendDataTypeController.h"

@interface AZSendDataTypeController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
/**  */
//@property(weak,nonatomic) UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@end

@implementation AZSendDataTypeController

- (IBAction)hexClick:(id)sender {
    
    if (self.scaleType) {
        self.scaleType(ScaleTypeHex);
    }
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (IBAction)octClick:(id)sender {
    
    if (self.scaleType) {
        self.scaleType(ScaleTypeOct);
    }
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)UTF8Click:(id)sender {
    
    if (self.scaleType) {
        self.scaleType(ScaleTypeUTF8);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrameNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)keyboardWillChangeFrameNotification:(NSNotification *)note
{
    CGRect keyEndRect =[note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    double duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    
    [UIView animateWithDuration:duration animations:^{
        CGFloat changY = AZScreenH - keyEndRect.origin.y;
        self.view.transform = CGAffineTransformMakeTranslation(0, -changY);
    }];
}
- (void)initUI
{
//    NSArray *buttonArr = @[@"交易时间:",@"手续费:",@"收款行:",@"收款账号:"];
//    CGFloat buttonW = 1.0 * self.bottomView.width / buttonArr.count ;
//    CGFloat buttonH = self.bottomView.height;
////    CGFloat buttonW
//    
//    for (int i = 0; i < buttonArr.count; i ++) {
//        
//        UIButton *button = [[UIButton alloc]init];
//        
//        [self.bottomView addSubview:button];
//    }
    
    self.scrollView.contentSize = CGSizeMake(0, self.scrollView.height);
    
    //线条属性
    CGFloat lineViewStartY = 0;
    CGFloat lineViewW = self.scrollView.width;
    CGFloat lineViewH = 1;
    
    //左边Label属性
    NSArray *leftLabelArr = @[@"交易时间:",@"手续费:",@"收款行:",@"收款账号:",@"收款户名",@"交易状态",@"流水号"];
    CGFloat leftlabelStartX = 0;
    CGFloat labelStartY = lineViewH;
    CGFloat labelW = self.scrollView.width * 0.2;
    CGFloat labelH = 42;
    
    //间隔
    CGFloat MarginH = labelH + lineViewH;
    
    //先加第一行的线条
    UIView *lineView = [[UIView alloc]init];
    CGFloat lineViewY = lineViewStartY;
    lineView.frame = CGRectMake(0, lineViewY, lineViewW, lineViewH);
    lineView.backgroundColor = [UIColor colorWithRed:(20/255.0) green:(20/255.0) blue:(20/255.0) alpha:0.5];
    [self.scrollView addSubview:lineView];
    
    for(int i = 0 ; i < leftLabelArr.count ; i++)
    {
        //线条属性
        UIView *lineView = [[UIView alloc]init];
        CGFloat lineViewY = lineViewStartY + (i+1) * MarginH;
        lineView.frame = CGRectMake(0, lineViewY, lineViewW, lineViewH);
        lineView.backgroundColor =[UIColor colorWithRed:(20/255.0) green:(20/255.0) blue:(20/255.0) alpha:0.5];
        [self.scrollView addSubview:lineView];
        
        //计算Frame
        CGFloat labelY = i * MarginH + labelStartY;
        
        //字体属性
        NSMutableDictionary *arri = [NSMutableDictionary dictionary];
        arri[NSFontAttributeName] = [UIFont systemFontOfSize:14];
        
        //左边Label属性
        UILabel *leftLabel = [[UILabel alloc]init];
        leftLabel.frame = CGRectMake(leftlabelStartX, labelY, labelW, labelH);
        leftLabel.text = leftLabelArr[i];
        leftLabel.textAlignment = NSTextAlignmentLeft;
        [leftLabel setFont:[UIFont systemFontOfSize:14]];
        [self.scrollView addSubview:leftLabel];

    }
}
@end
